package com.waji.http;

import java.math.BigDecimal;

import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVGeoPoint;
import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.SaveCallback;
import com.waji.local.SharedPrefer;

public class SendLocation {

	public void saveLocation(final Context context) {
		String id = SharedPrefer.ReadUsername(context);
		double longitude = SharedPrefer.ReadLongitude(context);
		double latitude = SharedPrefer.ReadLatitude(context);
		String address = SharedPrefer.ReadAddress(context);
		AVGeoPoint point = new AVGeoPoint(latitude, longitude);

		AVObject location = new AVObject("Location");
		location.put("id", id);
		location.put("address", address);
		location.put("whereCreated", point);
		location.saveInBackground(new SaveCallback() {
			@Override
			public void done(AVException e) {
				if (e == null) {
					Toast.makeText(context, "保存状态成功", 1).show();
				} else {
					Toast.makeText(context, "保存状态失败，请检查网络是否连接", 1).show();
				}
			}
		});
	}

}
